<?php
class AddressEntityBase extends EntityBase
{
	public $id;
	public $customerId;
	public $gender;
	public $company;
	public $firstName;
	public $lastName;
	public $street;
	public $suburb;
	public $postcode;
	public $city;
	public $countryId;
	public $stateId;	
	
	const INACTIVE = 0;
	const ACTIVE = 1;
	public function __construct($arrValue = null, $prefix = '')
	{
		if(!is_null($arrValue) && is_array($arrValue))
		{
			$this->id = (int) ($arrValue[$prefix . 'id']);			
			$this->customerId = strval ($arrValue[$prefix . 'customerId']);
			$this->gender = strval ($arrValue[$prefix . 'gender']);
			$this->company = strval ($arrValue[$prefix . 'company']);
			$this->firstName = strval ($arrValue[$prefix . 'firstName']);
			$this->lastName = strval ($arrValue[$prefix . 'lastName']);
			$this->street = strval ($arrValue[$prefix . 'street']);
			$this->suburb = strval ($arrValue[$prefix . 'suburb']);
			$this->postcode = strval ($arrValue[$prefix . 'postcode']);
			$this->city = strval ($arrValue[$prefix . 'city']);
			$this->countryId = strval ($arrValue[$prefix . 'countryId']);
			$this->stateId = strval ($arrValue[$prefix . 'stateId']);			
		}
	}

	/**
	 * Get status name of users
	 *
	 * @access public
	 *
	 * @return string name of status
	 *
	 */
	public function getStatusName()
	{
		$arrStatusList = self::getStatusList();
		return isset($arrStatusList["{$this->status}"]) ? $arrStatusList["{$this->status}"] : '';
	}

	/**
	 * Get list of users status
	 *
	 * @access public
	 *
	 * @return array of users status
	 *
	 */
	public static function getStatusList()
	{
		return array(self::INACTIVE	=> 'INACTIVE',
		self::ACTIVE 	=>'ACTIVE'		
		);
	}

	/**
	 * Get all fields for selecting columns
	 *
	 * @param string $alias: alias of table
	 * @param string $prefix
	 * @return string
	 */
	public static function getSelectColumns($alias, $prefix = '')
	{
		$arrValue = array(
						"{$alias}.id AS `{$prefix}id`",
						"{$alias}.customerId AS `{$prefix}customerId`",
						"{$alias}.gender AS `{$prefix}gender`",
						"{$alias}.company AS `{$prefix}company`",
						"{$alias}.firstName AS `{$prefix}firstName`",
						"{$alias}.lastName AS `{$prefix}lastName`",
						"{$alias}.street AS `{$prefix}street`",
						"{$alias}.suburb AS `{$prefix}suburb`",
						"{$alias}.postcode AS `{$prefix}postcode`",
						"{$alias}.city AS `{$prefix}city`",
						"{$alias}.countryId AS `{$prefix}countryId`",
						"{$alias}.stateId AS `{$prefix}stateId`"
		);

		return implode(',', $arrValue);
	}
}